const myUrl = 'http://www.ujiuye.com:8080/a/b/index.html?name=haha&age=100#test';

let url = new URL(myUrl);
console.log(url);
console.log(url.searchParams.get('name'));


/* 
URL {
  href: 'http://www.ujiuye.com:8080/a/b/index.html?name=haha&age=100#test',  //完整的url
  origin: 'http://www.ujiuye.com:8080',  //源
  protocol: 'http:',  //协议
  username: '',
  password: '',
  host: 'www.ujiuye.com:8080',  //域
  hostname: 'www.ujiuye.com',  //域名
  port: '8080',  //端口号
  pathname: '/a/b/index.html',  //路径  
  search: '?name=haha&age=100',  //查询字符串
  searchParams: URLSearchParams { 'name' => 'haha', 'age' => '100' },  //查询参数 （map数据结构）
  hash: '#test'  //哈希
}
*/